QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Examples of Metafile Structures

To illustrate the differences among the three types of metafile-- stream, normal, and database--we show how a single model ( Figure 2 ) is described in a text file of each type. The model consists of four occurrences (at different locations) of a colored box.

Figure 2 Four instantiations of a box

The following is a complete specification of each colored box shown in Figure 2 :

3DMetafile ( 1 5 Normal tableofcontents0> )
    box2:
    Container (
        Box (
            0 0 1                       # orientation
            1 0 0                       # majorAxis
            0 0 0                       # minorAxis
            0 1 0                       # origin
        )
        attributeset3:
        Container (
            AttributeSet ( )
            DiffuseColor ( 0.9 0.9 0.2 )
        )
    )
 

Offset

Hexadecimal code

ASCII

0000

3344 4D46 2020 2010 2001 2005 2020 2020

3DMF············

0010

2020 2020 2020 2020 636E 7472 2020 205C

········cntr···\

0020

626F 7820 2020 2030 2020 2020 2020 2020

box····0········

0030

3F80 2020 3F80 2020 2020 2020 2020 2020

?···?···········

0040

2020 2020 2020 2020 2020 2020 2020 2020

················

0050

3F80 2020 2020 2020 636E 7472 2020 201C

?·······cntr····

0060

6174 7472 2020 2020 6B64 6966 2020 200C

attr····kdif····

0070

3F66 6666 3F66 6666 3E4C CCCD

?fff?fff>L··

The expression Container (...) is used subsequently to abbreviate this specification. Transforms are used to place the box in various positions.

In a stream file, the specification of the box must occur four times, as shown in Listing 3 .

Listing 3 A stream metafile

3DMetafile ( 1 5 Stream
        tableofcontents0> )
    Container (
        Box (
            0 0 1                           # orientation
            1 0 0                           # majorAxis
            0 0 0                           # minorAxis
            0 1 0                           # origin
        )
        Container (
            AttributeSet ( )
            DiffuseColor ( 0.9 0.9 0.2 )
        )
    )
    Translate ( 3 0 0 )
    Container (
        Box (
            0 0 1                           # orientation
            1 0 0                           # majorAxis
            0 0 0                           # minorAxis
            0 1 0                           # origin
        )
        Container (
            AttributeSet ( )
            DiffuseColor ( 0.9 0.9 0.2 )
        )
    )
    Translate ( 0 3 0 )
    Container (
        Box (
            0 0 1                           # orientation
            1 0 0                           # majorAxis
            0 0 0                           # minorAxis
            0 1 0                           # origin
        )

        Container (
            AttributeSet ( )
            DiffuseColor ( 0.9 0.9 0.2 )
        )
    )
    Translate ( -3 1 0 )
    Container (
        Box (
            0 0 1                           # orientation
            1 0 0                           # majorAxis
            0 0 0                           # minorAxis
            0 1 0                           # origin
        )
        Container (
            AttributeSet ( )
            DiffuseColor ( 0.9 0.9 0.2 )
        )
    )
 

Offset

Hexadecimal code

ASCII

0000

3344 4D46 2020 2010 2001 2005 2020 2001

3DMF············

0010

2020 2020 2020 2020 636E 7472 2020 205C

········cntr···\

0020

626F 7820 2020 2030 2020 2020 2020 2020

box····0········

0030

3F80 2020 3F80 2020 2020 2020 2020 2020

?···?···········

0040

2020 2020 2020 2020 2020 2020 2020 2020

················

0050

3F80 2020 2020 2020 636E 7472 2020 201C

?·······cntr····

0060

6174 7472 2020 2020 6B64 6966 2020 200C

attr····kdif····

0070

3F66 6666 3F66 6666 3E4C CCCD 7472 6E73

?fff?fff>L··trns

0080

2020 200C 4040 2020 2020 2020 2020 2020

····@@··········

0090

636E 7472 2020 205C 626F 7820 2020 2030

cntr···\box····0

00A0

2020 2020 2020 2020 3F80 2020 3F80 2020

········?···?···

00B0

2020 2020 2020 2020 2020 2020 2020 2020

················

00C0

2020 2020 2020 2020 3F80 2020 2020 2020

········?·······

00D0

636E 7472 2020 201C 6174 7472 2020 2020

cntr····attr····

00E0

6B64 6966 2020 200C 3F66 6666 3F66 6666

kdif····?fff?fff

00F0

3E4C CCCD 7472 6E73 2020 200C 2020 2020

>L··trns········

0100

4040 2020 2020 2020 636E 7472 2020 205C

@@······cntr···\

0110

626F 7820 2020 2030 2020 2020 2020 2020

box····0········

0120

3F80 2020 3F80 2020 2020 2020 2020 2020

?···?···········

0130

2020 2020 2020 2020 2020 2020 2020 2020

················

0140

3F80 2020 2020 2020 636E 7472 2020 201C

?·······cntr····

0150

6174 7472 2020 2020 6B64 6966 2020 200C

attr····kdif····

0160

3F66 6666 3F66 6666 3E4C CCCD 7472 6E73

?fff?fff>L··trns

0170

2020 200C C040 2020 3F80 2020 2020 2020

·····@··?·······

0180

636E 7472 2020 205C 626F 7820 2020 2030

cntr···\box····0

0190

2020 2020 2020 2020 3F80 2020 3F80 2020

········?···?···

01A0

2020 2020 2020 2020 2020 2020 2020 2020

················

01B0

2020 2020 2020 2020 3F80 2020 2020 2020

········?·······

01C0

636E 7472 2020 201C 6174 7472 2020 2020

cntr····attr····

01D0

6B64 6966 2020 200C 3F66 6666 3F66 6666

kdif····?fff?fff

01E0

3E4C CCCD

>L··

Such repetition can make stream files lengthy. However, a stream file can be read by a parser having only sequential access to that file.

In a normal file, the box is completely specified once and is instantiated by reference three times. The file pointers and reference objects used to effect instantiations by reference are listed together in the table of contents. Other objects able to be referenced (such as the transforms) that are instantiated once only are not listed in the table of contents. The normal metafile permits the most compact representation of the model.

Listing 4A normal metafile

3DMetafile ( 1 5 Normal tableofcontents0> )
    box2:
    Container (
        Box (
            0 0 1                       # orientation
            1 0 0                       # majorAxis
            0 0 0                       # minorAxis
            0 1 0                       # origin
        )
        attributeset3:
        Container (
            AttributeSet ( )
            DiffuseColor ( 0.9 0.9 0.2 )
        )
    )
    translate4:
    Translate ( 3 0 0 )
    Reference ( 1 )
    translate5:
    Translate ( 0 3 0 )
    Reference ( 1 )
    translate6:
    Translate ( -3 1 0 )
    Reference ( 1 )
    tableofcontents0:
    TableOfContents (
        tableofcontents1>                   # next TOC
        2                                   # reference seed
        -1                                  # typeSeed
        1                                   # tocEntryType
        16                                  # tocEntrySize
        1                                   # nEntries
        1 box2>
        Box
    )

The pointer box2> is a file pointer correlated with the label box2 that precedes the specification of the box. Reference ( 1 ) is a reference object correlated with box2> (and thus with the specification of the box) in the table of contents. See "File Pointers" for an explanation of how instantiation by reference is accomplished through the use of these objects.

In a database file, the box is also instantiated by reference, and the file pointers and reference objects used to instantiate it are listed in the table of contents. With the exception of reference objects themselves, all other objects able to be referenced (the attribute set which contains the box's color attributes, and the transforms) are referenced, and all of these references are listed in the table of contents.

The contents of a database file can be discovered quickly by inspecting its tables of contents.

Listing 5A database metafile

3DMetafile ( 1 5 Database
        tableofcontents0> )
    box2:
    Container (
        Box (
            0 0 1                       # orientation
            1 0 0                       # majorAxis
            0 0 0                       # minorAxis
            0 1 0                       # origin
        )


        attributeset3:
        Container (
            AttributeSet ( )
            DiffuseColor ( 0.9 0.9 0.2 )
        )
    )
    translate4:
    Translate ( 3 0 0 )
    Reference ( 1 )
    translate5:
    Translate ( 0 3 0 )
    Reference ( 1 )
    translate6:
    Translate ( -3 1 0 )
    Reference ( 1 )
    tableofcontents0:
    TableOfContents (
        tableofcontents1>                   # next TOC
        6                                   # reference seed
        -1                                  # typeSeed
        1                                   # tocEntryType
        16                                  # tocEntrySize
        5                                   # nEntries
        1 box2>
        Box
        2 attributeset3>
        AttributeSet
        3 translate4>
        Translate
        4 translate5>
        Translate
        5 translate6>
        Translate
    )
 

Offset

Hexadecimal code

ASCII

0000

3344 4D46 2020 2010 2001 2005 2020 2002

3DMF············

0010

2020 2020 2020 20DC 636E 7472 2020 205C

········cntr···\

0020

626F 7820 2020 2030 2020 2020 2020 2020

box····0········

0030

3F80 2020 3F80 2020 2020 2020 2020 2020

?···?···········

0040

2020 2020 2020 2020 2020 2020 2020 2020

················

0050

3F80 2020 2020 2020 636E 7472 2020 201C

?·······cntr····

0060

6174 7472 2020 2020 6B64 6966 2020 200C

attr····kdif····

0070

3F66 6666 3F66 6666 3E4C CCCD 7472 6E73

?fff?fff>L··trns

0080

2020 200C 4040 2020 2020 2020 2020 2020

····@@··········

0090

7266 726E 2020 2004 2020 2001 7472 6E73

rfrn········trns

00A0

2020 200C 2020 2020 4040 2020 2020 2020

········@@······

00B0

7266 726E 2020 2004 2020 2001 7472 6E73

rfrn········trns

00C0

2020 200C C040 2020 3F80 2020 2020 2020

·····@··?·······

00D0

7266 726E 2020 2004 2020 2001 746F 6320

rfrn········toc·

00E0

2020 206C 2020 2020 2020 2020 2020 2006

···l············

00F0

FFFF FFFF 2020 2001 2020 2010 2020 2005

················

0100

2020 2001 2020 2020 2020 2018 626F 7820

············box·

0110

2020 2002 2020 2020 2020 2058 6174 7472

···········Xattr

0120

2020 2003 2020 2020 2020 207C 7472 6E73

···········|trns

0130

2020 2004 2020 2020 2020 209C 7472 6E73

············trns

0140

2020 2005 2020 2020 2020 20BC 7472 6E73

············trns

Figure 3 shows, side by side, the three principal forms of a metafile.

Figure 3 Types of metafiles


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |